<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <#include "../common/header.ftl"/>
    <script src="/js/plugins/My97DatePicker/WdatePicker.js"></script>
    <script src="/js/common.js"></script>

    <script>
        $(function () {
            $(".editBtn").click(function () {
                //清空模态框
                $("#strategyCatalogForm input").val("");
                $("#strategyCatalogForm select").val("");
                //接受数据,并判断是否有值,进行回显操作
                var json = $(this).data("json");
                if (json) {
                    $("#strategyCatalogForm input[name='name']").val(json.name);
                    $("#strategyCatalogForm select[name='strategy.id']").val(json.strategyId);
                    $("#strategyCatalogForm input[name='sequence']").val(json.sequence);
                    $("#strategyCatalogForm select[name='state']").val(json.state+"");

                    //隐藏域数据封装
                    $("#strategyCatalogForm input[name='id']").val(json.id);
                }else {
                    $("#strategyCatalogForm select[name='strategy.id']").val($("#strategyId").val());
                }
               $("#strategyCatalogModal").modal("show");
            })

            $("#saveBtn").click(function () {
                //alert(1);
               $("#strategyCatalogForm").ajaxSubmit(function () {
                   $.messager.confirm("温馨提示","操作成功",function(){
                       setTimeout(function () {
                           window.location.reload();
                       },1500);

                   });
               })
            })
            $.messager.model = {
                ok: {text: "确定"},
                cancel: {text: "取消"}
            };
        })
    </script>

    <style>
        #contentModal img{
            width: 100%
        }
        #contentModal .modal-body{
            max-height: 600px;
            overflow-y: scroll;
        }

    </style>
</head>

<body>
<div class="container">
<#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
		<#assign currentMenu = "strategyCatalog" />
				<#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="page-header">
                <h3>攻略分类管理</h3>
            </div>
            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/strategyCatalog/list.do">
                    <input type="hidden" name="currentPage" id="currentPage" value="1"/>
                    <div class="form-group">
                    </div>
                    <div class="form-group">
                        <label>攻略搜索</label>
                        <select class="form-control" name="strategyId" id="strategyId">
                            <#list strategies as s>
                                <option value="${s.id}">${s.title}</option>
                            </#list>
                        </select>
                        <script>
                            $("#searchForm select[name='strategyId']").val(${(qo.strategyId)!});
                        </script>
                    </div>
                    <div class="form-group">
                        <button id="query" type="submit" class="btn btn-success"><i class="icon-search"></i> 查询</button>
                        <a href="javascript:void(-1);" class="btn btn-success editBtn" id="addStrategyCatalogBtn">添加攻略分类</a>

                    </div>
                </form>
            </div>
            <div class="row">
                <table class="table">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>分类名称</th>
                        <th>所属攻略</th>
                        <th>排序</th>
                        <th>状态</th>
                    </tr>
                    </thead>
                    <tbody>
                    <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td>${entity.name}</td>
                        <td>${entity.strategy.title}</td>
                        <td>${entity.sequence}</td>
                        <td>${entity.stateName}</td>
                        <td>
                            <a role="button" class="editBtn" data-json='${entity.json}'>修改</a>
                        </td>

                    </tr>
                    </#list>
                    </tbody>
                </table>
                <#--分页-->
                  <#include "../common/page.ftl"/>
            </div>
        </div>
    </div>
</div>


<#--游记推荐模态框-->
<div id="strategyCatalogModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form id="strategyCatalogForm" class="form-horizontal" method="post" action="/strategyCatalog/saveOrUpdate.do" enctype="multipart/form-data" style="margin: -3px 118px">
                    <input type="hidden" name="id" value="" />
                    <div class="form-group">
                        <label class="col-sm-4 control-label">分类名称</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="name" placeholder="标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">所属攻略</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="strategy.id">
                                <#list strategies as s>
                                    <option value="${s.id}">${s.title}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">排序</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="sequence" placeholder="排序">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">状态</label>
                        <div class="col-sm-6">
                            <select class="form-control" autocomplete="off" name="state">
                                <option value="true">启用</option>
                                <option value="false">禁用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn btn-success" id="saveBtn" aria-hidden="true">保存</a>
                <a href="javascript:void(0);" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>



</body>
</html>